import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App)
import router from './router'

import 'lib-flexible'
import '@/assets/style/reset.css'
import '@/router/permission'

// 全局挂载pinia实例(registerStore全局注册，避免每次实例化后重复打包问题)
import { createPinia } from 'pinia'
import piniaPluginPersist from 'pinia-plugin-persist'
import { registerStore } from '@/store'
const store = createPinia()
store.use(piniaPluginPersist)
app.use(store)
registerStore()

// 引入vant样式
import 'vant/lib/index.css'
import '@/assets/style/vant.css'

// 引入svg
import '@/assets/svg/index'
import Svg from '@/assets/svg/index.vue'
app.component('z-svg', Svg)

// 全局挂载自定义组件
import components from '@/components'
components(app)

// 全局挂载自定义指令
import directives from '@/utils/directives'
directives(app)

// 事件总线（主要用于表单封装使用，业务代码不推荐，请使用vuex！）
import mitt from 'mitt'
app.config.globalProperties.$bus = mitt()

app.use(router).mount('#app')
